import request from '@/utils/request.js'

import axios from 'axios'

// 登录接口
export const loginAPI = data => {
  return request.post('/v1_0/authorizations', data)
}

// 获取用户信息的接口
export const getUserInfoAPI = () => {
  return request.get('/v1_0/user')
}

// 刷新用户token
export const exchangeTokenAPI = refreshToken => {
  return axios({
    method: 'PUT',
    url: 'http://toutiao-app.itheima.net/v1_0/authorizations',
    headers: {
      Authorization: `Bearer ${refreshToken}`
    }
  })
}

// 获取用户的个人资料
export const getUserProfileAPI = () => {
  return request.get('/v1_0/user/profile')
}

// 更新用户的头像
export const updataAvatorAPI = fd => {
  return request.patch('/v1_0/user/photo', fd)
}

// 更新用户的名称
export const updataUserProfileAPI = obj => {
  return request.patch('/v1_0/user/profile', obj)
}
